package corebusiness;

import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;

import thriftgenerated.CategoryStorage;

public class ThriftServer {
	private static final int PORTA = 7911;
	private void start() {
		try {
			TServerSocket serverTransport = new TServerSocket(PORTA);
			CategoryStorage.Processor<CategoryStorage.Iface> processor = new CategoryStorage.Processor<CategoryStorage.Iface>(new CategoryStorageImpl());
			TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
			System.out.println("Iniciando servidor na porta = " + PORTA);
			server.serve();
		} catch (TTransportException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		ThriftServer server = new ThriftServer();
		server.start();
	}
}
